<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>面单列表</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="__CSS__/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__CSS__/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__CSS__/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="__CSS__/animate.min.css" rel="stylesheet">
    <link href="__CSS__/style.min.css?v=4.1.0" rel="stylesheet">
    <link href="__CSS__/plugins/sweetalert/sweetalert.css" rel="stylesheet">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>面单列表</h5>
        </div>
        <div class="ibox-content">
           <div class="btn-group">
                <a href="JavaScript:;" target="_black">
                    <button class="btn btn-outline btn-primary" type="button" onclick="setAction();">批量确认</button>
                </a>
            </div>
           
            <!--搜索框开始-->
            <form id='commentForm' role="form" method="post" class="form-inline pull-right">
                <div class="content clearfix m-b">
                    <div class="form-group">
                        <input type="text" class="form-control" id="goods_name" name="goods_name" placeholder="商品名称">
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control" id="express_number" name="express_number" placeholder="快递单号">
                    </div>
                    <div class="form-group">
                        <input type="hidden" name="pack_id" value="{$pack_id}" id="pack_id">
                        <button class="btn btn-primary" type="button" style="margin-top:5px" id="search"><strong>搜 索</strong>
                        </button>
                    </div>
                </div>
            </form>
            <!--搜索框结束-->
            <div class="example-wrap">
                <div class="example">
                    <table id="cusTable">
                        <thead>
                        <th>
                            <div class="icheckbox-blue checked">
                                <input type="checkbox" id="checkbox-6" checked="" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255); border: 0px; opacity: 0;">
                                <ins class="iCheck-helper" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255); border: 0px; opacity: 0;">
                                    
                                </ins>
                            </div>
                        </th>
                        <!-- <th data-field="goods_id">商品ID</th> -->
                        <th data-field="goods_origin">图片</th>
                        <th data-field="goods_name" style="width: 200px">商品名称</th>
                        <th data-field="goods_num">商品</th>
                        <th data-field="express_code">快递公司</th>
                        <th data-field="express_number">快递单号</th>
                        <th data-field="nickname">用户昵称</th>
                        <th data-field="note">管理员备注</th>
                        <th data-field="create_time">创建时间</th>
                        <th data-field="status">状态</th>
                        <th data-field="operate">操作</th>
                        </thead>
                    </table>
                </div>
            </div>
            <!-- End Example Pagination -->
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>
<script src="__JS__/jquery.min.js?v=2.1.4"></script>
<script src="__JS__/bootstrap.min.js?v=3.3.6"></script>
<script src="__JS__/content.min.js?v=1.0.0"></script>
<script src="__JS__/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="__JS__/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="__JS__/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="__JS__/plugins/suggest/bootstrap-suggest.min.js"></script>
<script src="__JS__/plugins/layer/laydate/laydate.js"></script>
<script src="__JS__/plugins/sweetalert/sweetalert.min.js"></script>
<script src="__JS__/plugins/layer-v3.1.1/layer.js"></script>
<script type="text/javascript">

    function initTable() {
        //先销毁表格
        $('#cusTable').bootstrapTable('destroy');
        //初始化表格,动态从服务器加载数据
        $("#cusTable").bootstrapTable({
            method: "get",  //使用get请求到服务器获取数据
            url: "./index", //获取数据的地址
            striped: true,  //表格显示条纹
            pagination: true, //启动分页
            // showRefresh:true,//是否显示刷新按钮。
            //showToggle:true,//是否显示切换视图（table/card）按钮
            // search:true,//是否启用搜索框。
            // searchText:'快递单号',//初始化搜索文字。
            //showColumns:true,//是否显示内容列下拉框。
            // searchOnEnterKey:true,//按回车触发搜索方法
            pageSize: 10,  //每页显示的记录数
            pageNumber:1, //当前第几页
            pageList: [5, 10, 15, 20, 25],  //记录数可选列表
            sidePagination: "server", //表示服务端请求
            paginationFirstText: "首页",
            paginationPreText: "上一页",
            paginationNextText: "下一页",
            paginationLastText: "尾页",
            queryParamsType : "undefined",
            queryParams: function queryParams(params) {   //设置查询参数
                var param = {
                    pageNumber: params.pageNumber,
                    pageSize: params.pageSize,
                    express_number:$('#express_number').val(),
                    searchText:$('#goods_name').val(),
                    pack_id:$('#pack_id').val(),
                };
                return param;
            },
            columns: [{
                    checkbox: true,  
                    visible: true                  //是否显示复选框  
            }], 
            onLoadSuccess: function(res){  //加载成功时执行
                if(111 == res.code){
                    window.location.reload();
                }
                layer.msg("加载成功", {time : 1000});
            },
            onLoadError: function(){  //加载失败时执行
                layer.msg("加载数据失败");
            }
        });
    }

    $(document).ready(function () {
        //调用函数，初始化表格
        initTable();

        //当点击查询按钮的时候执行
        $("#search").bind("click", initTable);
    });

    //标记商品不符合
    function setIncompatible(goods_id){
        layer.confirm('确认标记商品不符合？', function(index){
            layer.prompt({
              formType: 2,
              value: '商品不符',
              title: '请输入备注  <span style="color:#FF5722">备注将以短信邮件形式通知客户</span>',
              area: ['450px', '250px'] //自定义文本域宽高
            }, function(value, index, elem){
              $.post('{:url("Goods/note")}', {goods_id:goods_id,note: value}, function(data, textStatus, xhr) {
                if (data.code==0) {
                   setTimeout(function() {
                        initTable();
                   }, 2000); 
                }
                layer.msg(data.msg);
              },'json');
              layer.close(index);
            });
          layer.close(index);
        });       
    }

    function setAction(key){
        var rows= $('#cusTable').bootstrapTable('getSelections');
        if(rows.length<=0){  
             layer.alert('最少选中一行');
        }else{  
            var b=JSON.stringify(rows); 
            var url="{:url('Goods/setAction')}";  
           
            $.ajax({  
                dataType: "json",  
                traditional:true,//这使json格式的字符不会被转码  
                data: {"datalist":b},  
                type: "post",   
                url: url,  
                success : function (data) {  
                    layer.alert('操作成功',function(){
                        initTable();
                    });

                },  
                error : function (data){  
                    layer.alert(data.responseText); 
                }  
            });  
        }   
        
    }


</script>
</body>
</html>
